<?php

namespace App\Http\Requests\Admin\Panx\Product;

use App\Http\Requests\ApiRequest;
use Illuminate\Foundation\Http\FormRequest;

/**
 * @property int customer_id
 * @property int is_sale
 * @property int is_deleted
 * @property int per_page
 * @property string brand_id
 * @property string category_id
 * @property string keyword
 * @property string sort_column
 * @property string sort_by
 */
class ProductIndexRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'customer_id' => 'nullable|int|min:1',
            'is_sale'     => 'nullable|int|in:0,1',
            'is_deleted'  => 'nullable|int|in:0,1',
            'brand_id'    => 'nullable|int|min:1',
            'category_id' => 'nullable|int|min:1',
            'keyword'     => 'nullable|string',
        ];
    }

    /**
     * @return array
     */
//    public function messages()
//    {
//        return [
//            'customer_id.*' => '代理的id必须是数值',
//            'is_sale.*'     => '是否出售的状态必须是数值',
//            'is_deleted.*'  => '是否删除的状态必须是数值',
//            'brand_id.*'    => '产品的品牌id必须是数值',
//            'category_id.*' => '产品类别id必须是数值',
//            'keyword.*'     => '产品名称/标题的值必须是字符串',
//        ];
//    }
}
